<template>
	<view class="wrap">
		<online-form :key="date" keyIndex='date' :formId="formId" :entryId="entryId" ref="form" @changeSub="barType = 1 - barType"
			@close="closed" />
	</view>
</template>

<script>
	import {
		getBoundingClientRect
	} from "@/utils";
	
	export default {
		data() {
			const {
				windowWidth,
				statusBarHeight
			} = uni.getSystemInfoSync()
			const rect = getBoundingClientRect(windowWidth, statusBarHeight);
			return {
				windowWidth: windowWidth,
				statusBarHeight: statusBarHeight,
				titleNavHeight: (rect.top - statusBarHeight) * 2 + rect.height,
				formId: undefined,
				entryId: undefined,
				emptyWidth: rect.left - 10,
				barType: 0,
				date: Number((new Date()).valueOf()) - 10,
			}
		},
		methods: {
			go_back() {
				if (this.barType === 0)
					uni.navigateBack();
				else
					this.$refs.form.closeSubPage();
			},
			toggleDelete() {
				this.$refs.form.toggleDelete();
			},
		},
		onLoad(e) {
			// console.log(e)
			const item = JSON.parse(decodeURIComponent(e.passData))
			this.formId = item.formId
			this.entryId = item.entryId
		},
		onShow(){
			this.date = Number((new Date()).valueOf()) - 10
		}
	}
</script>

<style scoped lang="less">
	.nav-bar {
		position: absolute;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding-left: 20rpx;

		.text {
			max-width: 60%;
			margin: 0 auto;
			color: #323233;
			font-weight: 500;
			font-size: 30rpx;
		}

		.nav-right {
			display: flex;

			.mobile-font {
				color: #707070;
				font-size: 36rpx;

				&+.mobile-font {
					margin-left: 12rpx;
				}
			}
		}
	}
</style>